package org.thunms.framework.utils;

import org.apache.commons.lang3.StringUtils;

public class UtilNull {
	private static final String NULL_STRING="";
	private static final int NULL_INTEGER=0;
	private static final Double NULL_DOUBLE=0.00;
	public static String formatNullToString(Object o){
		if(o!=null&&o.toString().length()>0){
			return o.toString();
		}else{
			
			return NULL_STRING;
		}
	}
	
	public static Integer formatNullToInteger(Object o){
		if(o!=null&&o.toString().length()>0){
			return Integer.parseInt(o.toString());
		}else{
			return NULL_INTEGER;
			
		}
	}
	public static Double formatNullToDouble(Object o){
		if(o!=null&&o.toString().length()>0){
			return Double.parseDouble(o.toString());
			
		}else{
			return NULL_DOUBLE;
		}
	}
	
	
	public static String checkNull(String s){
		if(StringUtils.isNotBlank(s)){
			return s;
		}else{
			return NULL_STRING;
		}
		
	}
	
	public static String checkNull(Double s){
		if(s!=null){
			return s.toString();
		}else{
			return NULL_STRING;
		}
		
	}

}
